import http from '@/utils/http'
export const addCourseAPI = (coursename,img,courseintro) => {
    
    return http({
      url:'/course/save',
      method:'POST',
      data:{
        name:coursename,
        img:img,
        description:courseintro
      }
    })
  }

export const getCourseAPI = ()=>{
    return http({
        url:'/course/findByTeacher',
        method:'GET',
        params:{
          status:0
        }
    })
}
export const deleteCourseAPI = (id)=>{
  return http({
    url:'/course/delete',
    method:'GET',
    params:{
      id:id
    }
  })
}
export const addlessonAPI = (courseid,lessonname,videourl)=>{
  return http({
    url:'/lesson/save',
    method:'POST',
    data:{
      courseId:courseid,
      title:lessonname,
      videoUrl:videourl
      
    }
  })
}

export const getCourseIntro = (id)=>{
  return http({
    url:'/course/findById',
    method:'GET',
    params:{
      id:id
    }
  })

}
export const getTeaById = (teid)=>{
  return http({
    url:'/user/findByTeacherId',
    method:'GET',
    params:{
      teacherId:teid
    }
  })
}
export const getLessonAPI = (id)=>{
  return http({
    url:'/lesson/findByCourseId',
    method:'GET',
    params:{
      id:id
    }
  })
}

export const addStudentAPI = (id)=>{
  return http({
    url:'/course/addStudent',
    method:'GET',
    params:{
      courseId:id
    }
  })
}

export const studyflagAPI =(id)=>{
  return http({
    url:'/course/studiedFlag',
    method:'GET',
    params:{
      courseId:id
    }
  })
}
export const findmyCourse = ()=>{
  return http({
    url:'/course/myCourse',
    method:'GET',
  
  })
}

export const updateCourse = (courseid,couname,couintro,couimg)=>{
  return http({
    url:'/course/update',
    method:'POST',
    data:{
      id:courseid,
      name:couname,
      img:couimg,
      description:couintro
    }

  })
}

export const getStudentAPI = (id)=>{
  return http({
    url:'/user/findByCourseId',
    method:'GET',
    params:{
      courseId:id
    }
  })
}

export const exitCourseAPI = (id)=>{
  return http({
    url:'/course/subStudent',
    method:'GET',
    params:{
      courseId:id
    }
  })
}
export const deleteLesson = (id)=>{
  return http({
    url:'/lesson/delete',
    method:'GET',
    params:{
      id:id

    }
  })
}


export const likeFlagAPI = (id)=>{
  return http({
    url:'/course/likeFlag',
    method:'GET',
    params:{
      courseId:id
    }
  })

}

export const likeCourse = (id)=>{
  return http({
    url:'/course/like',
    method:'GET',
    params:{
      courseId:id
    }
  })
}

export const delikeCourse = (id)=>{
  return http({
    url:'/course/delike',
    method:'GET',
    params:{
      courseId:id
    }
  })
}

export const  getLessonDetail = (id)=>{
  return http({
    url:'/lesson/findById',
    method:'GET',
    params:{
      id:id
    }
  })

}